<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0028)http://jdbi.org/archive.html -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>


<title>abacus-common</title>

<script type="text/javascript" src="./css/ga.js"></script>
<script type="text/javascript">
	if (top.location != self.location)
		top.location.replace(self.location);
</script>

<link href="./css/css" rel="stylesheet" type="text/css"></link>
<link href="./css/css(1)" rel="stylesheet" type="text/css"></link>
<link rel="stylesheet" href="./css/syntax.css" type="text/css"></link>
<link rel="stylesheet" href="./css/screen.css" type="text/css"></link>

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-65247258-1', 'auto');
  ga('send', 'pageview');
</script>

</head>
<body>
	<div id="site">
		<h1>
			<a href="./index.html">abacus-common</a> <span id="navigation"> <a href="./docs.html">Docs</a> | <a href="./download.html">Download</a>
				| <a href="./api-docs/index.html">Javadoc</a> | <a href="./faq.html">FAQ</a> | <a href="./community.html">Community</a>
			</span>
		</h1>
	</div>

	<div id="content">

		<div id="page">

			<h1>Functional Programming in Java 8</h1>
			<p>
				Here are some very good tutorials and a simple sample:
				<br />
				<a href="https://leanpub.com/whatsnewinjava8/read">https://leanpub.com/whatsnewinjava8/read</a>
				<br />
				<a href="./QConNY2015-MauriceNaftalin-LetsGettotheRapidsJava8StreamPerformance.pdf">Understanding Java 8 Stream Performance</a> from Maurice Naftalin
				<br />
				<a href="http://gee.cs.oswego.edu/dl/html/StreamParallelGuidance.html">When to use parallel streams</a> and <a href="./api-docs/com/landawn/abacus/util/stream/BaseStream.html#parallel-int-com.landawn.abacus.util.stream.BaseStream.Splitor-">Java Doc</a>
				<br />
			</p>
			<p>
			Extra features supported by abacus-common:
				<li>Stream is supported for primitive type except boolean: 
				<a href="./api-docs/com/landawn/abacus/util/stream/CharStream.html">CharStream</a>, 
				<a href="./api-docs/com/landawn/abacus/util/stream/ByteStream.html">ByteStream</a>, 
				<a href="./api-docs/com/landawn/abacus/util/stream/ShortStream.html">ShortStream</a>, 
				<a href="./api-docs/com/landawn/abacus/util/stream/IntStream.html">IntStream</a>, 
				<a href="./api-docs/com/landawn/abacus/util/stream/LongStream.html">LongStream</a>, 
				<a href="./api-docs/com/landawn/abacus/util/stream/FloatStream.html">FloatStream</a>, 
				<a href="./api-docs/com/landawn/abacus/util/stream/DoubleStream.html">DoubleStream</a> and 
				<a href="./api-docs/com/landawn/abacus/util/stream/Stream.html">Stream</a>.
				</li>
				<li>More convenient APIs are provided by: 
				<a href="./api-docs/com/landawn/abacus/util/stream/Collectors.html">Collectors</a> and 
				<a href="./api-docs/com/landawn/abacus/util/stream/Stream.html">Stream</a>
				</li>
				<li>Integrated with different data structures: 
				<a href="./api-docs/com/landawn/abacus/DataSet.html">DataSet</a>, 
				<a href="./api-docs/com/landawn/abacus/util/Multimap.html">Multimap</a>, 
				<a href="./api-docs/com/landawn/abacus/util/Multiset.html">Multiset</a> and primitive list.
				</li>
				<li>Faster Java8 stream implementation for array/collection. Here is the performance test result: <a href="./stream_performance_test_result.txt">stream_performance_test_result.txt</a> by below <a href="./StreamPerformanceTest.java">code</a>: </li>
				<br />
				With the support of Lambda/Stream and <a href="./api-docs/com/landawn/abacus/DataSet.html">DataSet</a>, abacus-common provides a set of VERY POWERFUL APIs to process/analyze data. 
			</p>


			<p></p>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%">Stream<span style="color: #666666">.</span><span style="color: #7D9029">of</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;abc&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;123&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;ab123&quot;</span><span style="color: #666666">).</span><span style="color: #7D9029">filter</span><span style="color: #666666">(</span>str <span style="color: #666666">-&gt;</span> str<span style="color: #666666">.</span><span style="color: #7D9029">startsWith</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;a&quot;</span><span style="color: #666666">)).</span><span style="color: #7D9029">forEach</span><span style="color: #666666">(</span><span style="color: #A0A000">N:</span><span style="color: #666666">:</span>println<span style="color: #666666">);</span>
<span style="color: #408080; font-style: italic">// abc</span>
<span style="color: #408080; font-style: italic">// ab123</span>

List<span style="color: #666666">&lt;</span>String<span style="color: #666666">&gt;</span> strs <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asList</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;Hello Java&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;I LIKE Functional Programming&quot;</span><span style="color: #666666">);</span>

<span style="color: #408080; font-style: italic">// average length of words in the strings.</span>
Stream<span style="color: #666666">.</span><span style="color: #7D9029">of</span><span style="color: #666666">(</span>strs<span style="color: #666666">).</span><span style="color: #7D9029">flatMap2</span><span style="color: #666666">(</span>str <span style="color: #666666">-&gt;</span> str<span style="color: #666666">.</span><span style="color: #7D9029">split</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot; &quot;</span><span style="color: #666666">)).</span><span style="color: #7D9029">collect</span><span style="color: #666666">(</span>Collectors<span style="color: #666666">.</span><span style="color: #7D9029">averagingDouble</span><span style="color: #666666">(</span>str <span style="color: #666666">-&gt;</span> str<span style="color: #666666">.</span><span style="color: #7D9029">length</span><span style="color: #666666">()));</span>
<span style="color: #408080; font-style: italic">// 5.833333333333333</span>

<span style="color: #408080; font-style: italic">// count the characters in upper case.</span>
Stream<span style="color: #666666">.</span><span style="color: #7D9029">of</span><span style="color: #666666">(</span>strs<span style="color: #666666">).</span><span style="color: #7D9029">flatMapToChar</span><span style="color: #666666">(</span>str <span style="color: #666666">-&gt;</span> Stream<span style="color: #666666">.</span><span style="color: #7D9029">from</span><span style="color: #666666">(</span>str<span style="color: #666666">.</span><span style="color: #7D9029">toCharArray</span><span style="color: #666666">())).</span><span style="color: #7D9029">filter</span><span style="color: #666666">(</span>ch <span style="color: #666666">-&gt;</span> Character<span style="color: #666666">.</span><span style="color: #7D9029">isUpperCase</span><span style="color: #666666">(</span>ch<span style="color: #666666">)).</span><span style="color: #7D9029">count</span><span style="color: #666666">();</span>
<span style="color: #408080; font-style: italic">// 9</span>
</pre></div>



		<br></br>
	</div>
</body>

</html>